package Function;

public class Function4 extends Function{

	public Function4(){
		// xi e [-10,10]
		xmin = -10;
		xmax = 10;
	}
	
	public int bitLength(double accuracy){
		return 2 * super.bitLength(accuracy);
	}
	
	public double evaluate(double[] parameters) {
		// f(x1, x2) = sum[i=1,5](i*cos((i+1)*x1+i)) * sum[i=1,5](i*cos((i+1)*x2+i))
		return sum(parameters[0]) * sum(parameters[1]);
	}
	
	private double sum(double x){
		double resul = 0;
		for (int i = 1; i <= 5; i++){
			resul += i * Math.cos((i+1) * x + i);
		}
		return resul;
	}
}
